package controller;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import pojo.User;
import service.AdminUserService;

import java.util.List;

@Controller
public class AdminUser {
    @RequestMapping("toDelete")
    public String initDelete(Model model){
        List<User> u=adminUserService.sAU();
        model.addAttribute("u",u);
        return "adminDeleteOneUser";}
    @Autowired
    private AdminUserService adminUserService;
    @RequestMapping("/deleteUser")
    public String deleteUser(Integer uid, Model model){
        int a= adminUserService.dU(uid);
        if (a>0){
            List<User> u=adminUserService.sAU();
            model.addAttribute("u",u);
            model.addAttribute("msg","删除成功！");
            return "adminDeleteOneUser";
        }
            List<User> u=adminUserService.sAU();
            model.addAttribute("u",u);
            model.addAttribute("msg","删除失败！");
            return "adminDeleteOneUser";
    }
}
